package cn.jorian.framework.controller;

import cn.jorian.framework.bean.ResponseResult;
import cn.jorian.framework.entity.User;
import cn.jorian.framework.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;

@RestController
@RequestMapping("/user")
public class LoginController {

    @Autowired
    private LoginService<HashMap<String, String>> loginService;

    @GetMapping("/login")
    public ResponseResult<HashMap<String, String>> login(@RequestParam String username, @RequestParam String password) {
        User user = new User();
        user.setUsername(username);
        user.setPassword(password);
        return loginService.login(user);
    }

    @GetMapping("/logout")
    public ResponseResult<HashMap<String, String>> logout() {
        return loginService.logout();
    }

}
